package com.fr.chart.core;

import com.fr.base.FCloneable;
import com.fr.base.Style;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.painter.AbstractPainter;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;

public class GlyphPainter extends AbstractPainter
{
  private Glyph glyph;

  public GlyphPainter(Glyph paramGlyph)
  {
    this.glyph = paramGlyph;
  }

  public void setGlyph(Glyph paramGlyph)
  {
    this.glyph = paramGlyph;
  }

  public Glyph getGlyph()
  {
    return this.glyph;
  }

  public void paint(Graphics paramGraphics, int paramInt1, int paramInt2, Style paramStyle)
  {
    if (this.glyph == null)
      return;
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
    Rectangle localRectangle = this.glyph.getShape().getBounds();
    double d = Math.min(paramInt1 / localRectangle.getWidth(), paramInt2 / localRectangle.getHeight());
    localGraphics2D.scale(d, d);
    this.glyph.draw(localGraphics2D);
    localGraphics2D.scale(1.0D / d, 1.0D / d);
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    GlyphPainter localGlyphPainter = (GlyphPainter)super.clone();
    if (this.glyph != null)
      localGlyphPainter.setGlyph((Glyph)this.glyph.clone());
    return localGlyphPainter;
  }
}